Skip to content

fix: usable error when install-script deps are missing; prefer sha256sum#116

Merged
renecannao merged 1 commit into
masterfrom
fix/install-script-dependency-hints
May 14, 2026
Merged

fix: usable error when install-script deps are missing; prefer sha256sum#116
renecannao merged 1 commit into
masterfrom
fix/install-script-dependency-hints

Conversation

@renecannao
Copy link
Copy Markdown

Summary

Addresses #111. Three improvements to scripts/dbdeployer-install.sh:

  1. Prefer sha256sum, fall back to shasum. The script previously required shasum (a Perl utility default on macOS, not on Linux). On Ubuntu 24.04 minimal images this was the only missing tool — but sha256sum from GNU coreutils is preinstalled there. Both tools produce/consume the same <hex> <filename> checksum format used in checksums.txt, so the verification step works with either. This removes the failure mode entirely on Linux without forcing the user to install anything.
  2. Report all missing tools at once. The old loop exited on the first missing tool, so a user with two missing deps would have to install, re-run, install, re-run. We now collect every missing required tool (tar, curl, gzip, and a checksum tool if neither sha256sum nor shasum is present) and print them all together before exiting.
  3. Per-tool install hints for the common platforms. For each missing tool we print the install command for Debian/Ubuntu, RHEL/Fedora, Alpine, and macOS — so the user knows exactly what to install instead of just "tool 'X' not found".

Before (issue #111 reproducer on Ubuntu 24.04)

$ curl -s .../dbdeployer-install.sh | bash
tool 'shasum' not found

After

On Ubuntu 24.04: succeeds — sha256sum is preinstalled and used automatically.

If a tool is missing, the user sees something like:

Required tool(s) not found in $PATH:
  - tar
      Debian/Ubuntu: sudo apt-get install -y tar
      RHEL/Fedora:   sudo dnf install -y tar
      Alpine:        sudo apk add tar
      macOS:         preinstalled
  - sha256sum (GNU coreutils) or shasum (Perl Digest::SHA)
      Debian/Ubuntu: sudo apt-get install -y coreutils           # provides sha256sum
                  or sudo apt-get install -y libdigest-sha-perl  # provides shasum
      RHEL/Fedora:   sudo dnf install -y coreutils               # provides sha256sum
                  or sudo dnf install -y perl-Digest-SHA         # provides shasum
      Alpine:        sudo apk add coreutils                      # provides sha256sum
                  or sudo apk add perl-utils                     # provides shasum
      macOS:         shasum is preinstalled

Test plan

  • bash -n scripts/dbdeployer-install.sh — syntax OK
  • Simulated Ubuntu 24.04 (sha256sum present, shasum missing): script proceeds, checksum_cmd selects sha256sum -c -
  • Simulated fully empty $PATH: all four tools reported together with hints, exit code 1
  • Verified shasum -a 256 and sha256sum produce a mutually-compatible <hex> <file> file format, so sha256sum -c accepts the existing release checksums.txt
  • CI install-script matrix (ubuntu-22.04, ubuntu-24.04, macos-14, macos-15) all have at least one of sha256sum/shasum preinstalled, so install_script_test.yml continues to pass

Notes

The change does not attempt distro auto-detection — keeping a /etc/os-release parse out of the install script avoids adding maintenance burden the rest of the file doesn't have. The hints are short enough that users can self-select.

…256sum

Addresses #111. The script already checked for `tar curl gzip shasum` and
exited if any was missing, but the error ("tool 'shasum' not found") gave
the user no path to recovery. On Ubuntu 24.04 minimal images this was the
*only* missing tool — `shasum` is a Perl utility shipped by default on macOS
but not Linux. Linux has `sha256sum` (GNU coreutils) preinstalled instead.

Changes:
- Accept either `sha256sum` (preferred — preinstalled on most Linux distros)
  or `shasum` (preinstalled on macOS). Both produce/consume the same
  `<hex>  <file>` format used in `checksums.txt`, so the verification step
  works unchanged with either. On Ubuntu 24.04 this removes the failure
  entirely.
- Collect every missing required tool (tar, curl, gzip, plus a checksum tool
  if neither sha256sum nor shasum is present) before exiting, so users only
  have to install once and re-run.
- Print per-tool install hints covering Debian/Ubuntu, RHEL/Fedora, Alpine,
  and macOS so users know exactly what package to install.

No behavior change on systems that already have `shasum`: the script picks
`sha256sum` if present, falls back to `shasum` otherwise. The CI matrix
(ubuntu-22.04, ubuntu-24.04, macos-14, macos-15) all have at least one of
the two preinstalled, so existing install-script tests keep passing.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@renecannao has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 1 second before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 73f22a4d-88b2-46e5-97f0-afde2a5e71ba

📥 Commits

Reviewing files that changed from the base of the PR and between 857149f and e0c4ae5.

📒 Files selected for processing (1)
  • scripts/dbdeployer-install.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/install-script-dependency-hints

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the dbdeployer-install.sh script by improving dependency checking and checksum verification. It now collects all missing tools and provides platform-specific installation hints instead of exiting immediately. Additionally, it dynamically selects between sha256sum and shasum for integrity checks. Review feedback recommends replacing the custom path-checking function with the more robust command -v builtin and using Bash arrays for the checksum command to ensure proper argument handling and avoid word-splitting issues.

Comment on lines +78 to 84
for tool in tar curl gzip
do
found_tool=$(exists_in_path $tool)
if [ -z "$found_tool" ]
if [ -z "$(exists_in_path "$tool")" ]
then
echo "tool '$tool' not found"
exit 1
missing_tools+=("$tool")
fi
done
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The custom exists_in_path function (defined at line 49) is potentially fragile because it splits $PATH on spaces (line 51), which will fail if any directory in the path contains a space. Since this script is using Bash, it is more robust and idiomatic to use the command -v builtin to check for the existence of executables.

Suggested change
for tool in tar curl gzip
do
found_tool=$(exists_in_path $tool)
if [ -z "$found_tool" ]
if [ -z "$(exists_in_path "$tool")" ]
then
echo "tool '$tool' not found"
exit 1
missing_tools+=("$tool")
fi
done
for tool in tar curl gzip
do
if ! command -v "$tool" >/dev/null 2>&1
then
missing_tools+=("$tool")
fi
done
References
  1. Use the command -v builtin instead of manual path searching to robustly check for executable existence in shell scripts.

Comment on lines +86 to +96
# Pick a checksum command: prefer sha256sum (Linux default), fall back to shasum (macOS default).
checksum_cmd=""
if [ -n "$(exists_in_path sha256sum)" ]
then
checksum_cmd="sha256sum -c -"
elif [ -n "$(exists_in_path shasum)" ]
then
checksum_cmd="shasum -a 256 -c -"
else
missing_tools+=("sha256sum-or-shasum")
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to use a Bash array to store commands with their arguments. This avoids potential issues with word splitting and is considered a best practice for handling commands dynamically in Bash. Additionally, using command -v here is more robust than the custom exists_in_path function.

Suggested change
# Pick a checksum command: prefer sha256sum (Linux default), fall back to shasum (macOS default).
checksum_cmd=""
if [ -n "$(exists_in_path sha256sum)" ]
then
checksum_cmd="sha256sum -c -"
elif [ -n "$(exists_in_path shasum)" ]
then
checksum_cmd="shasum -a 256 -c -"
else
missing_tools+=("sha256sum-or-shasum")
fi
# Pick a checksum command: prefer sha256sum (Linux default), fall back to shasum (macOS default).
checksum_cmd=()
if command -v sha256sum >/dev/null 2>&1
then
checksum_cmd=(sha256sum -c -)
elif command -v shasum >/dev/null 2>&1
then
checksum_cmd=(shasum -a 256 -c -)
else
missing_tools+=("sha256sum-or-shasum")
fi
References
  1. Use arrays to store commands and their arguments in Bash to avoid word splitting issues and improve maintainability.

grep "$filename" "$checksum_file" | shasum -a 256 -c -
check_exit_code "shasum -c for $filename"
# $checksum_cmd was selected in STEP 2 — either `sha256sum -c -` or `shasum -a 256 -c -`.
grep "$filename" "$checksum_file" | $checksum_cmd
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Execute the checksum_cmd array using the "${array[@]}" syntax to ensure arguments are handled correctly without being subject to word splitting.

Suggested change
grep "$filename" "$checksum_file" | $checksum_cmd
grep "$filename" "$checksum_file" | "${checksum_cmd[@]}"

@renecannao renecannao merged commit 37a55bf into master May 14, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant